<?php 
	include_once "Information.php"; 
	include_once "termin.php"; 
	session_start(); 
	if($_SESSION['login']!=2) die ("Kein Zugriff"); 
	$schule = $_SESSION['schule'];
	$termine = $schule->getTermine();
	if(isset($_POST['add'])){
		$_SESSION['add'];
		header("Location: terminplaner.php");
		exit();
	}
	if(isset($_POST['change'])){
		$_SESSION['change']=$_POST['terminid'];
		header("Location: terminchanger.php");
		exit();
	}
?>

<html>
	<head>
		<title>
			Terminmanager
		</title>
	</head>
	<body>
		<form method="POST" name="termin" action="<?php echo $_SERVER["SCRIPT_NAME"]; ?>">
			<table>
			<?php
			foreach($termine as $termin){
				printf('<tr>
								 <td>
								 	Veranstaltung
								 </td>
								 <td>
								 	Datum
								 </td>
								 <td>
									 <input type="hidden" name="terminid" value="'.$termin->getTerminID().'">
								 </td>
								</tr>');
				echo "<tr><td>";
				echo $termin->getBeschr();
				echo "</td><td>";
				echo $termin;
				echo '</td><td><input type="submit" name="change" value="&auml;ndern"></td></tr>';
				}
				if($schule->countTermine()<3){
					echo '<tr><td><input type="submit" name="add" value="hinzuf&uuml;gen"></td></tr>';
				}
				?>
			</table>
		</form>	 	
	</body>
</html>
	